<template>
	<view class="user-miner-detail">
		<view class="header">
			<view class="miner">
				<view class="icon">
					<image src="../../../static/icon/pool_dig_img.png" mode="widthFix"></image>
				</view>
				<view class="miner-info">
					<view class="miner-title">SID云矿机一期</view>
					<view class="miner-content">
						<view class="item">ID{{miner.order_sn}}</view>
						<view class="item">到期时间：{{miner.end_time}}</view>
					</view>
				</view>
			</view>
			<view class="main-box">
				<view class="main-title">
					<view class="main">矿机收益</view>
					<view class="sub text-dark" @click="productionLog">收益明细 ></view>
				</view>
				<view class="miner-static">
					<view class="static-title">累计收益/昨日收益</view>
					<view class="row">
						<view class="col">
							<view class="number">{{miner.total_production}}</view>
							<view class="unit">SID</view>
						</view>
						<view class="col">
							<view class="number">{{miner.yesterday_production}}</view>
							<view class="unit">SID</view>
						</view>
					</view>
				</view>
			</view>
			<view class="miner-info">
				<view class="info-title">矿机信息</view>
				<view class="info-content">
					每天产币到账，您可以直接提币到钱包/交易所
				</view>
			</view>
			<view class="miner-detail-box">
				<view class="col">
					<view class="box-title">SID日产出</view>
					<view class="box-content">
						<view class="number">{{miner.day_amount}}</view>
						<view class="unit">SID</view>
					</view>
				</view>
				<view class="col center">
					<view class="box-title">有效算力</view>
					<view class="box-content">
						<view class="number">{{miner.power}}</view>
						<view class="unit">G</view>
					</view>
				</view>
				<view class="col">
					<view class="box-title">剩余周期</view>
					<view class="box-content">
						<view class="number">{{miner.left_day}}</view>
						<view class="unit">天</view>
					</view>
				</view>
			</view>
			<view class="miner-more-box">
				<view class="col">
					<view class="box-title">开始时间</view>
					<view class="box-content">{{miner.start_time}}</view>
				</view>
				<view class="col">
					<view class="box-title">已运行时长</view>
					<view class="box-content">{{miner.running_day}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from "@/utils/api/pool/index.js"
	import util from '@/common/util.js'
	export default {
		data() {
			return {
				miner: {
					"id": "",
					"uid": "",
					"order_sn": "",
					"name": "",
					"total_get_amount": "",
					"start_time": "",
					"create_time": "",
					"end_time": "",
					"day_amount": "",
					"miner_id": "",
					"status": "",
					"running_day": "",
					"left_day": "",
					"total_production": "0",
					"yesterday_production": 0

				},
				minerProfile: {
					total_score1: 0.09121,
					total_score3: 1.64091,
					yesterday_score1: 0,
					yesterday_score3: 0,
				},
				id: 0,
			}
		},
		onNavigationBarButtonTap() {
			uni.navigateBack({

			})
		},
		onLoad(e) {
			if (typeof(e.data) == "undefined" || e.data == null || e.data == "") {
				this.id = e.id;
				if (this.id == 0) {
					util.showError("error id")
					uni.reLaunch({
						url: "../../home"
					})
				} else {
					this.getUserMiner(this.id);
				}
			} else {
				this.miner = JSON.parse(e.data)
			}

			console.log("miner", JSON.stringify(this.miner))
		},
		methods: {
			productionLog() {
				uni.navigateTo({
					url: "miner-production-log"
				})
			},
			async getUserMiner(id) {
				let post = {
					id: this.id
				}
				let res = await api.userMinerDetail(post)
				if (res.status == 1) {
					this.miner = res.data;
				}
			},
			records() {
				uni.navigateTo({
					url: "../currency/recordCurrency/recordCurrency?type=miner"
				})
			}
		}
	}
</script>

<style lang="scss">
	view {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}

	page {
		background-color: #141F31;
	}

	.user-miner-detail {
		.header {
			border-top: none;

			.miner {
				flex-direction: row;
				background-color: #071824;
				padding: 15px;

				.icon {
					width: 60px;
					height: 60px;
					justify-content: center;

					image {
						width: 100%;
					}
				}

				.miner-info {
					padding: 0;
					padding-left: 15px;
					justify-content: center !important;
					border-top: 1px solid transparent;

					.miner-title {
						font-weight: bold;
					}

					.miner-content {
						.item {
							line-height: 100%;
							opacity: .5;
							font-size: 12px;
						}
					}
				}
			}

			.main-box {
				padding: 15px;
				border-top: 1px solid #071824;

				.main-title {
					flex-direction: row;
					justify-content: space-between;

					.main {
						font-weight: bold;
					}

				}

				.miner-static {
					.static-title {
						color: #999;
						text-align: center;
						padding: 5px 0;
					}

					.row {
						flex-direction: row;
						justify-content: space-between;
						padding-bottom: 10px;

						.col {
							width: 50%;
							flex-direction: row;
							text-align: center;
							justify-content: center;

							.number {
								font-weight: bold;
								font-size: 120%;
								line-height: 25px;
							}

							.unit {
								justify-content: flex-end;
								font-size: 10px;
								padding-left: 5px;
							}
						}
					}
				}
			}

			.miner-info {
				padding: 15px;
				border-top: 1px solid #071824;

				.info-title {
					font-weight: bold;
					padding-bottom: 5px;
				}

				.info-content {
					color: #999999;
				}
			}

			.miner-detail-box {
				flex-direction: row;
				justify-content: space-between;
				padding: 15px;
				padding-top: 30px;

				.col.center {
					border: 10px solid #0853C3;
					border-radius: 100%;
					width: 100px;
					height: 100px;
					box-shadow: 0 0 15px rgba(8, 83, 195, .5);
				}

				.col {
					justify-content: center;

					.box-title {
						justify-content: center;
						text-align: center;
						color: #999999;
						font-size: 12px;
					}

					.box-content {
						flex-direction: row;
						justify-content: center;

						.number {
							font-weight: bold;
							line-height: 15px;
							font-size: 20px;
							line-height: 30px;
						}

						.unit {
							font-weight: bold;
							justify-content: flex-end;
							font-size: 12px;
						}
					}
				}
			}

			.miner-more-box {
				justify-content: space-between;
				flex-direction: row;
				padding: 15px;

				.col {
					.box-title {
						color: #999;
						font-size: 12px;
						text-align: center;
						justify-content: center;
					}

					.box-content {
						font-weight: bold;
						justify-content: center;
						text-align: center;
					}
				}
			}
		}
	}
</style>
